package com.jiepos.mpos.biz.transaction.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.transaction.service.StlCustomService;
import com.jiepos.mpos.common.entity.App_Stl_CustomEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 会员提现清算报表业务类
 * @ProjectName:  [mpos1] 
 * @Package com.jiepos.mpos.biz.transaction.controller 
 * @author 肖志伟
 * @version 1.0
 * @since 2017年11月7日 上午9:27:13
 * @history（历次修订内容、修订人、修订时间等）
 * @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("stlCustom")
public class StlCustomController extends BaseController{
	
	@Autowired
	private StlCustomService stlCustomService;
	
	
	/**
	 * 会员提现清算报表列表页
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getStlCustomList.do")
	public ModelAndView getStlCustomList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView modelAndView = new ModelAndView("/module/transaction/stlcustom/stlcustom_list");
		return super.getDetail(request, response, modelAndView);
	}
	
	/**
	 * 会员提现清算报表详细数据
	 * @param request
	 * @param response
	 * @param pagination
	 * @param appStlCustomEntity
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param custom_name
	 * @param custom_login_id
	 * @return
	 */
	@RequestMapping("/getStlCustomListJson.do")
	@ResponseBody
	public Map getStlCustomListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Stl_CustomEntity appStlCustomEntity, String stl_dt_start,
			String stl_dt_end, String custom_name, String custom_login_id) {
		return stlCustomService.getStlCustomList(request, pagination, appStlCustomEntity,
				stl_dt_start, stl_dt_end, custom_name, custom_login_id);
	}
	
	/**
	 * 会员提现清算报表导出
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param logStlMchntSumEntity
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param custom_no
	 * @param custom_name
	 * @param custom_phone
	 * @param ins_cd
	 */
	@RequestMapping("/exportIStlCustomLists.do")
	@ResponseBody
	public void exportIStlCustomLists(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Stl_CustomEntity appStlCustomEntity, String stl_dt_start,
			String stl_dt_end, String custom_name, String custom_login_id) {
		super.clearCookie(request, response);
		String fileName = "HuiYuanTiXianQingSuanBaoBiao.xls";
		String msg = stlCustomService.exportIStlCustomLists(fileName, request, response, pagination,
				appStlCustomEntity, stl_dt_start, stl_dt_end, custom_name, custom_login_id);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, fileName);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}
	
	/**
	 * 平安打款报表页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/pinganExcelList.do")
	public ModelAndView exportPinganExcel(HttpServletRequest request, HttpServletResponse response){
		ModelAndView modelAndView = new ModelAndView("/module/transaction/stlcustom/pinganExcel_list");
		return super.getDetail(request, response, modelAndView);
	}
	
	@RequestMapping("/pinganExcelJson.do")
	@ResponseBody
	public Map pinganExcelJson(HttpServletRequest request, HttpServletResponse response, Pagination pagination) {
		return stlCustomService.getPinganReport(request, pagination);
	}
	
	@RequestMapping("/exportPinganExcel.do")
	@ResponseBody
	public void exportPinganExcel(HttpServletRequest request, HttpServletResponse response, String fileName, String filePath){
		super.setFileParam(request, response, fileName, filePath);
	}

}
